package edu.ccut.saturn.studio.logic.policy;

import java.util.List;

import org.eclipse.gef.DragTracker;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Handle;
import org.eclipse.gef.handles.MoveHandle;
import org.eclipse.gef.handles.ResizableHandleKit;
import org.eclipse.gef.handles.ResizeHandle;
import org.eclipse.swt.graphics.Cursor;

public class CustomResizableHandleKit extends ResizableHandleKit {
	
	public static void addHandle(GraphicalEditPart part, List handles,
			int direction) {
		handles.add(createHandle(part, direction));
	}

	public static void addHandle(GraphicalEditPart part, List handles,
			int direction, DragTracker tracker, Cursor cursor) {
		handles.add(createHandle(part, direction, tracker, cursor));
	}

	/**
	 * 只添加线，不添加小方框。
	 * 
	 * @param part
	 * @param handles
	 * @see ResizableHandleKit
	 */
	public static void addHandles(GraphicalEditPart part, List<?> handles) {
		addMoveHandle(part, handles);
	}

	public static void addMoveHandle(GraphicalEditPart f, List handles) {
		handles.add(moveHandle(f));
	}

	public static void addMoveHandle(GraphicalEditPart f, List handles,
			DragTracker tracker, Cursor cursor) {
		handles.add(moveHandle(f, tracker, cursor));
	}

	static Handle createHandle(GraphicalEditPart owner, int direction) {
		ResizeHandle handle = new CustomResizeHandle(owner, direction);
		// handle.setDragTracker(new ResizeTracker(direction));
		return handle;
	}

	static Handle createHandle(GraphicalEditPart owner, int direction,
			DragTracker tracker, Cursor cursor) {
		ResizeHandle handle = new ResizeHandle(owner, direction);
		handle.setDragTracker(tracker);
		handle.setCursor(cursor);
		return handle;
	}

	public static Handle moveHandle(GraphicalEditPart owner) {
		return new SaturnMoveHandle(owner);
	}

	public static Handle moveHandle(GraphicalEditPart owner,
			DragTracker tracker, Cursor cursor) {
		MoveHandle moveHandle = new SaturnMoveHandle(owner);
		moveHandle.setDragTracker(tracker);
		moveHandle.setCursor(cursor);
		return moveHandle;
	}

}
